package com.yunfangdata.service.impl;

import com.yunfangdata.domain.RecruitPlanDetail;
import com.yunfangdata.mapper.RecruitPlanDetailMapper;
import com.yunfangdata.mapper.RecruitPlanMapper;
import com.yunfangdata.query.ApplicantQueryObject;
import com.yunfangdata.query.QueryObject;
import com.yunfangdata.service.IRecruitPlanDetailService;
import com.yunfangdata.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class RecruitPlanDetailServiceImpl implements IRecruitPlanDetailService {


    @Autowired
    private RecruitPlanDetailMapper mapper;

    @Autowired
    private RecruitPlanMapper recruitMapper;

    public void save(RecruitPlanDetail entity) {
        mapper.insert(entity);
    }

    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    public void update(RecruitPlanDetail entity) {
        mapper.updateByPrimaryKey(entity);
    }

    public RecruitPlanDetail get(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    public List<RecruitPlanDetail> list() {
        return mapper.selectAll();
    }




    public PageResult queryByRecruit(QueryObject qo) {
        int total = mapper.queryForCount(qo);

        if (total == 0){
            return new PageResult();
        }
        List<RecruitPlanDetail> rows = mapper.queryForList(qo);
        return new PageResult(total,rows);
    }

    public PageResult query(QueryObject qo) {
        int total = mapper.queryForCount(qo);

        if (total == 0){
            return new PageResult();
        }
        List<RecruitPlanDetail> rows = mapper.queryForList(qo);
        return new PageResult(total,rows);
    }

    public PageResult queryById(ApplicantQueryObject qo ,Long id) {
        int total =1;
        RecruitPlanDetail recruitPlanDetail = mapper.selectByPrimaryKey(id);
        List<RecruitPlanDetail> rows=new ArrayList<>();
        rows.add(recruitPlanDetail);
        return new PageResult(total,rows);
    }
}
